<?php

/**
 * Ignus Framework
 *
 * @author Sergey Palyanov <sergey.palyanov@gmail.com>
 * @link http://code.google.com/p/ignus-php/
 * @license http://apache.org/licenses/LICENSE-2.0
 * @package Ignus
 * @subpackage Mock
 * @since 0.1
 */

namespace Ignus\Test\Mock;

/**
 * @package Ignus
 * @subpackage Mock
 * @since 0.5
 */
class Stub
{
    /**
     * Mock subject
     * @var object
     */
    private $mock;

    /**
     * Name of expected method invokation
     * @var string
     */
    private $methodName;

    /**
     * Expected arguments of method invokation
     * @var array
     */
    private $arguments;

    /**
     *
     * @param object $mock
     */
    public function __construct($mock)
    {
        $this->mock = $mock;
    }

    /**
     * @param string $name
     * @param array $arguments
     * @return Stub
     */
    public function __call($name, array $arguments)
    {
        $this->methodName = $name;
        $this->arguments = $arguments;
        return $this;
    }

    /**
     * Define stubbed method return value
     * @param mixed $value
     * @return void
     */
    public function returns($value)
    {
        $this->mock->registerStub($this->methodName, $this->arguments, $value);
    }
}
